<template>
  <view>
    <uni-card class="card" :is-shadow="false" is-full @click="supply('')">
      <uni-title
        type="h4"
        align="center"
        :title="detail.projectName + '-成交公示'"
      ></uni-title>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">项目名称</text>
      <text class="right">{{
        detail.projectName ? detail.projectName : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full v-show="specSHow">
      <text class="left">转出方式</text>
      <text class="right">{{
        detail.transferMethod ? detail.transferMethod : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">交易方式</text>
      <text class="right">{{
        detail.transactions ? detail.transactions : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">项目底价</text>
      <text class="right"
        >{{ detail.listingPrice ? detail.listingPrice : "暂无" }}元</text
      >
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">成交时间</text>
      <text class="right">{{
        detail.doneTime ? detail.doneTime : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">标的区域</text>
      <text class="right">{{
        detail.location ? detail.location : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">转出方</text>
      <text class="right">{{
        detail.transferor ? detail.transferor : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">受让方</text>
      <text class="right">{{
        detail.transfereeName ? detail.transfereeName : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full v-show="specSHow">
      <text class="left">转出面积/数量</text>
      <text class="right">{{
        detail.transferAmount + detail.transferAmountUnit
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full v-show="specSHow">
      <text class="left">转出期限</text>
      <text class="right">
	  {{detail.transferStartTime?detail.transferStartTime.split(" ")[0] :''}}至{{detail.transferEndTime?detail.transferEndTime.split(" ")[0]:''}}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">成交价格</text>
      <text class="right">{{
        detail.donePrice + (detail.donePriceUnit ? detail.donePriceUnit : "元")
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">联系电话</text>
      <text class="right">{{
        detail.consultPhone ? detail.consultPhone : "暂无"
      }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full v-show="specSHow">
      <text class="left">备注</text>
      <text class="right">{{ detail.remark ? detail.remark : "暂无" }}</text>
    </uni-card>
    <uni-card class="card" :is-shadow="false" is-full>
      <text class="left">附件</text>
      <text class="right">
        <view v-if="!detail.files">暂无</view>
        <view v-else>
          <view
            style="color: #2880e4; margin-right: 20rpx"
            v-for="(item, index) in detail.files"
            :key="index"
            @click="xiazai(item)"
            >{{ item.name }}</view
          >
        </view>
      </text>
    </uni-card>
  </view>
</template>
<script>
import { projectDonePublic } from "@/utils/api.js";
export default {
  data() {
    return {
      title: "Hello",
      city: 0,
      value: 0,
      cityList: [
        { value: 0, text: "临沂市" },
        { value: 1, text: "罗庄区" },
        { value: 2, text: "河东区" },
        { value: 3, text: "兰山区" },
      ],
      rangeList: [
        { value: 0, text: "招标公示" },
        { value: 1, text: "中标公示" },
        { value: 2, text: "成交公示" },
      ],
      detail: {},
      specSHow:true
    };
  },
  onLoad(e) {
    let data = JSON.parse(e.data);
    if (e.jieshu) {
      this.getDetail2(data);
    } else {
      this.getDetail(data.id);
    }
  },
  methods: {
    async getDetail2(e) {
      let res = await projectDonePublic.getDetail1({
        dataId: e.dataId,
        dataType: e.dataType,
      });
      this.detail = res.data;
	  if(this.detail.projectTypeCode =='6' || this.detail.projectType =='13'){
		this.specSHow = false;
	  }
    },
    async getDetail(e) {
      let res = await projectDonePublic.getDetail({
        id: e,
      });
      console.log(res.data);
      this.detail = res.data;
	  if(this.detail.projectTypeCode =='6' || this.detail.projectType =='13'){
		this.specSHow = false;
	  }
    },
    change(e) {
      console.log("e:", e);
    },
    xiazai(e) {
      console.log(e);
      console.log(this.$baseUrl);
      uni.downloadFile({
        url: this.$baseUrl + e.url, //仅为示例，并非真实的资源
        success: (res) => {
          console.log(res);
          if (res.statusCode === 200) {
            console.log("下载成功");
            var oA = document.createElement("a");
            oA.download = e.name; // 设置下载的文件名，默认是'下载'
            oA.href = res.tempFilePath; //临时路径再保存到本地
            document.body.appendChild(oA);
            oA.click();
            oA.remove(); // 下载之后把创建的元素删除
          }
        },
      });
    },
  },
};
</script>

<style scoped lang="less">
.card {
  width: 100%;
}
.left {
  width: 35%;
  float: left;
  font-size: 14px;
  font-family: PingFang-SC-Medium, PingFang-SC;
  font-weight: 500;
  color: #8d8d8d;
  line-height: 20px;
}
.right {
  width: 60%;
  float: right;
  font-size: 15px;
  font-family: PingFang-SC-Medium, PingFang-SC;
  font-weight: 500;
  color: #000000;
  line-height: 21px;
}
.project-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  .project-info {
    width: 92%;
    margin-top: 20rpx;
    margin-bottom: 20rpx;
    display: flex;
    .info-left {
      image {
        width: 220rpx;
        height: 300rpx;
        border-radius: 10rpx;
      }
    }
    .info-right {
      width: 470rpx;
      margin-left: 8rpx;
      display: flex;
      justify-content: space-around;
      flex-direction: column;
      .project-detail {
        font-size: 28rpx;
        color: #303030;
      }
    }
  }
}
</style>
